<%@ include file="IsAdmin.jsp"%><%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*,database.*" %>
<%
try{
DBCon db1 = new DBCon();
int sizeOfP = db1.countUsers(" where type <> 'admin'");
ResultSet res2 = db1.getUsers(" where type <> 'admin'");
String [] usernamesP = new String[sizeOfP];
String[] types= new String[sizeOfP];
for(int i=0;res2.next();i++)
 {
    usernamesP[i] = res2.getString("username");
    types[i] = res2.getString("status");
 }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head> 
		<%@ include file="../master/head.jsp" %>
                 
		<script type="text/javascript" src="js/drag_drop_1.js"></script>
		<link rel="STYLESHEET" href="styles/project.css" type="text/css">
		<link rel="stylesheet" href="styles/control_1.css" type="text/css"/>
		<script type="text/javascript">
                     var isThereIsChange = false;
function check() {
var it = new Array();
<%
        int i=0;
	for(;i<usernamesP.length;i++)
	{
		out.println("it["+i+"] = document.getElementById('"+usernamesP[i]+"');");
	}
        
                
%>
for(var i=0;i<it.length;i++)
{
	if(it[i] != null && it[i].parentNode.id == "DragContainer4")
	{
		document.getElementById("in"+i).value = "accepted";
	}
	else if(it[i] != null && it[i].parentNode.id == "DragContainer5")
	{
		document.getElementById("in"+i).value = "pending";
	}
        else if(it[i] != null && it[i].parentNode.id == "DragContainer6")
	{
		document.getElementById("in"+i).value = "dropped";
	}
	isThereIsChange = true;
        
}
var links = document.body.getElementsByTagName("a");
for(var i=0;i<links.length;i++)
{
    links[i].onclick = function() {
        return confirm("You made changes on users status\nDo you want to discard it? if you do not click save changes button");
    }
}
return true;
}
		</script>
	</head>
	<body>
		<div id="container">
			<div id="wrapper">
				<div id="sidebar">
					<div id="sb_top">
						<%@ include file="../master/sbTop.jsp" %>
					</div>
					
					<div class="sb_content">
						
						<!--##########-->
							<!-- Start Menu -->
							<%@ include file="../master/adminMenu.jsp" %>
							
							<!-- Profile -->
							<%@ include file="../master/profile.jsp" %>
							
							<!-- links -->
							<%@ include file="../master/links.jsp" %>
						<div class="copyright">
							<%@ include file="../master/copyright.jsp" %>
						</div>
						
					</div> <!-- /sb_content -->
				</div> <!-- /sidebar -->
					
					
				<!-- Top -->
				<div id="header">
					<%@ include file="../master/header.jsp" %>
				</div>
				
				
				<!-- Start main content -->
				<div id="content">
					<div id="intro">
						<div class="intro_t">
							<h1><span>..</span>Welcome to<span>..</span></h1>
							<h2 >student project managment system</h2>
							
						</div>
					</div> <!-- /intro -->
                                         <TABLE BORDER="0" width="100%">
                                            <tr>
                                                <td><center><h2>Accepted users</h2></center></td>
                                                <td><center><h2>Pended users</h2></center></td>
                                                <td><center><h2>Rejected users</h2></center></td>
                                            </tr>
                                         </TABLE>
					<DIV id=Demo4 width="100%">
						<DIV class=DragContainer id=DragContainer4 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < usernamesP.length; x++) {
                                     if(types[x].equals("accepted"))
                                         {
							%>
							<DIV class=DragBox id="<%=usernamesP[x]%>" overClass="OverDragBox" dragClass="DragDragBox" ondblclick="openWindow(<%=usernamesP[x]%>)"><%=usernamesP[x]%></DIV>
							<%
                                        }}
							%>
						</DIV>
						<DIV class=DragContainer id=DragContainer5 overClass="OverDragContainer">
							<%
				 for (int x = 0; x < usernamesP.length; x++) {
                                     if(types[x].equals("pending")){
							%>
							<DIV class=DragBox id="<%=usernamesP[x]%>" overClass="OverDragBox" dragClass="DragDragBox" ondblclick="openWindow(<%=usernamesP[x]%>)"><%=usernamesP[x]%></DIV>
							<%
				    }}
							%>
						</DIV>
                                                 <DIV class=DragContainer id=DragContainer6 overClass="OverDragContainer">
							<%
                                for (int x = 0; x < usernamesP.length; x++) {                        
				 if(types[x].equals("dropped")){
							%>
							<DIV class=DragBox id="<%=usernamesP[x]%>" overClass="OverDragBox" dragClass="DragDragBox" ondblclick="openWindow(<%=usernamesP[x]%>)"><%=usernamesP[x]%></DIV>
							<%
				    }}
							%>
						</DIV>
                                                 <form name="types" action="changeStatus.jsp" method="get">
						<%
                                                
                        int x=0;
			for(;x<usernamesP.length;x++)
			{
				%>
				<input type="hidden" id="in<%=x%>" name="<%=usernamesP[x]%>" value="<%=types[x]%>" />
				<%
			}
			}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

                        %>
                         <center><input type="submit" value="save changes"></center>
                                                </form>
					</DIV>
                                         	
				</div> <!-- /content -->
				
			</div> <!-- /wrapper -->
			<div class="clear">&nbsp;</div> <!-- Important! Fix the problem of height in Firefox -->
		</div> <!-- /Container -->
			
		
	</body>
</html>